import request from '@/utils/request'

export default {
  getActivityList(searchModel) {
    return request({
      url: '/activity/list',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        activityName: searchModel.activityName,
        activityUserName: searchModel.activityUserName
      }
    });
  },
  addActivity(activityInfo) {
    return request({
      url: '/activity',
      method: 'post',
      data: activityInfo
    });
  },
  updateActivity(activityInfo) {
    return request({
      url: '/activity',
      method: 'put',
      data: activityInfo
    });
  },
  saveActivity(activityInfo) {
    if (activityInfo.id == null && activityInfo.id == undefined) {
      return this.addActivity(activityInfo);
    }
    return this.updateActivity(activityInfo);
  },
  getActivityById(id) {
    return request({
      //url: '/user/' + id,
      url: `/activity/${id}`,
      method: 'get'
    });
  },
  deleteActivityById(id) {
    return request({
      url: `/activity/${id}`,
      method: 'delete'
    });
  },
  isHaveActivity(activityName) {
    return request({
      url: '/activity/isHaveActivity',
      method: 'get',
      params:{
        activityName:activityName
      }
    });
  }
}
